package com.example.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.domain.Stu;
import com.example.service.IStuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

//@RestController
@RequestMapping("/stus")
public class StuController2 {

    @Autowired
    private IStuService stuService;

    @GetMapping
    public List<Stu> getAll(){
        return stuService.list();
    }

    @PostMapping
    public Boolean save(@RequestBody Stu stu){
        return stuService.save(stu);
    }

    @PutMapping
    public Boolean update(@RequestBody Stu stu){
        return stuService.updateById(stu);
    }

    @DeleteMapping("{id}")
    public Boolean delete(@PathVariable Integer id){
        return stuService.delete(id);
    }

    @GetMapping("{id}")
    public  Stu getById(@PathVariable Integer id){
        return stuService.getById(id);
    }

    @GetMapping("{currentPage}/{pageSize}")
    public IPage<Stu> getPage(@PathVariable int currentPage,@PathVariable int pageSize){
        return stuService.getPage(currentPage,pageSize);
    }

}
